package ebj.common.system;

import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class IPUtil {

    private static final String DEFAULT_IP="0.0.0.0";

    public static String getIPAddress(HttpServletRequest sr) {
        String ipAddress = sr.getRemoteAddr();
        return ipAddress;
    }

    public static String getLocalIP(){
        String ip = null;
        try {
            ip = InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            return DEFAULT_IP;
        }
        return ip;
    }


}
